layui.define(['layer', 'jquery', 'element'], function (exports) {
    var layer = layui.layer,
        $ = layui.jquery,
        element = layui.element,
        form = layui.form;
    var obj = {
        openTabs: function (url) {
            var tabs = $("#left-nav li");
            var a = [];
            var that = this;
            tabs.each(function (x, y) {
                $(y).find("a").each(function (i, j) {
                    if ($(j).attr("href") != 'undefined') {
                        a.push($(j));
                    }
                })
            });
            $.each(a, function (x, y) {
                $(y).attr("tab-href", $(y).attr("href"));
                $(y).attr("lay-id", x);
                var href = $(y).attr("href");
                $(y).removeAttr("href");
                if (((href.split('/')).length - 1 ) > 0) {
                    $(y).click(function () {
                        if ($(y).attr("lay-id")<=0){
                            $(y).attr("href",$(y).attr("tab-href"));
                        }else{
                            var tabList = $("#tab-list #tab-box .layui-tab-title li");
                            var tabListStr = "";
                            tabList.each(function (a, b) {
                                tabListStr += $(b).attr("lay-id") + "-";
                            });
                            if ((tabListStr.split($(y).attr("lay-id"))).length > 1) {
                                element.tabChange("tabs", $(y).attr("lay-id"));
                            } else {
                                var iframe = '<iframe src="' + href + '" frameborder="0" class="content-iframe '+x+'"></iframe>';
                                element.tabAdd("tabs", {
                                    title: '<span>' + $(y).children("cite").text() + '</span>'
                                    , content: iframe
                                    , id: x
                                });
                                element.tabChange("tabs", x);
                            }
                        }
                    });
                }
            });
        }
    }
    exports('tabs', obj); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
});